home *** CD-ROM | disk | FTP | other *** search
- Path: tst.hk.super.net!usenet
- From: chiasw@hk.super.net
- Newsgroups: comp.lang.c++
- Subject: Please help me to sort 'adjacent items'
- Date: 28 Mar 1996 15:34:36 GMT
- Organization: Hong Kong SuperNET
- Message-ID: <4jebic$jn5@tst.hk.super.net>
- NNTP-Posting-Host: max2-17.hk.super.net
- X-Newsreader: AIR News 3.X (SPRY, Inc.)
-
- I have a sorting problem and is looking for a quick solution:
- Consider the following table represents some adjacency information:
-
- B - C
- C - L
- D - E
- E - M
- F - G
- G - N
- H - K
- I - M
- J - K
- J - L
- M - O
- N - O
-
- that is, item B is adjacent to C, C is adjacent to L, D is adjacent to E
- etc.
-
- The problem is now to sort all items which are directly adjacent to each
- other into different groups, therefore, they should be sorted into
- two groups:
- B - C - L - J - K - H
- and
- O - N - M - I - E - D - G - F
-
- For we human, the problem can be done easily on paper by inspection.
- Is there any simple algorithm to implement this sort of sorting on
- computer?
-
- Please lend me some help. Many thanks!
-
- SW Chia
- email: chiasw@hk.super.net
-
-
-
-